<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>
Should see "foo" and "bar" centered in their own boxes. The "baz" line should be in its own red box, but not centered.
</p>
<div id="sample" contenteditable>foo<br>bar<br>baz</div>
<div id="log"></div>
<script>
test(function() {
    var selection = window.getSelection();
    var sample = document.getElementById('sample');

    selection.collapse(sample, 0);
    selection.extend(sample.childNodes[2], 1);
    document.execCommand('justifyCenter');

    assert_equals(sample.innerHTML, '<div style="text-align: center;">foo</div><div style="text-align: center;">bar</div>baz', 'innerHTML');
    assert_false(selection.isCollapsed, 'isCollapsed');
    assert_equals(selection.anchorNode, sample.firstChild.firstChild, 'anchorNode');
    assert_equals(selection.anchorOffset, 0, 'anchorOffset');
    assert_equals(selection.focusNode, sample.childNodes[1].firstChild, 'focusNode');
    assert_equals(selection.focusOffset, 1, 'focusOffset');
});
</script>
